/**
 * 文  件  名：  UserInfoDaoProxy.java
 * 工  程  名：  7You
 * 创建日期：  2013-10-13
 * 创建作者：  杨  强
 */
package com.qiyou.dao.proxy;

import java.sql.Connection;
import java.sql.SQLException;
import java.util.List;

import com.qiyou.dao.IUserInfoDao;
import com.qiyou.dao.impl.UserInfoDaoImpl;
import com.qiyou.db.IDatabase;
import com.qiyou.entity.UserInfo;
import com.qiyou.util.DBUtil;

/**
 * 用户信息数据操作代理类
 * 
 * @author 杨 强
 * 
 */
public class UserInfoDaoProxy implements IUserInfoDao {
    private Connection conn = null;
    private IUserInfoDao userInfoDao = null;

    public UserInfoDaoProxy(IDatabase database) {
        this.conn = database.getConnection();
        this.userInfoDao = new UserInfoDaoImpl(conn);
    }

    @Override
    public boolean doUpdate(UserInfo userInfo) throws SQLException {
        boolean result = false;
        if (null != userInfo) {
            try {
                result = userInfoDao.doUpdate(userInfo);
            } catch (SQLException e) {
                throw e;
            } finally {
                DBUtil.closeConnection(conn);
            }
        }
        return result;
    }

    @Override
    public UserInfo getUserInfo(String userID) throws SQLException {
        UserInfo result = null;
        if ((null != userID) && (!userID.isEmpty())) {
            try {
                result = userInfoDao.getUserInfo(userID);
            } catch (SQLException e) {
                throw e;
            } finally {
                DBUtil.closeConnection(conn);
            }
        }
        return result;
    }

    @Override
    public List<UserInfo> getUserInfo(Object... params) throws SQLException {
        List<UserInfo> result = null;
        if (null != params) {
            try {
                result = userInfoDao.getUserInfo(params);
            } catch (SQLException e) {
                throw e;
            } finally {
                DBUtil.closeConnection(conn);
            }
        }
        return result;
    }

}
